package com.lau.videoeffect.multiplayer

import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.lau.videoeffect.R
import kotlinx.android.synthetic.main.multi_media_player_activity.*
import java.io.File

class MultiMediaPlayerActivity : AppCompatActivity() {

    private lateinit var mGLRenderer: GLRenderer

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.multi_media_player_activity)
        val file1 = File("/mnt/sdcard/video/test.mp4")
        val file2 = File("/mnt/sdcard/video/test1.mp4")
        if (!file1.exists() || !file2.exists()) {
            Toast.makeText(this, "请确定/mnt/sdcard/video/目录下方有相应视频输入源", Toast.LENGTH_SHORT).show()
            finish()
        } else {
            mGLRenderer = GLRenderer(this, file1.absolutePath, file2.absolutePath)
            mGLSurfaceView.setEGLContextClientVersion(3)
            mGLSurfaceView.setRenderer(mGLRenderer)
        }
    }

    override fun onResume() {
        super.onResume()
        mGLRenderer?.onResume()
    }

    override fun onPause() {
        super.onPause()
        mGLRenderer?.onPause()
    }

    override fun onStop() {
        super.onStop()
        mGLRenderer?.onRelease()
    }
}